/**
 * 消息记录查看
 */
define(["app", "js/services/MessageBox", "js/services/MuseService"], function (app) {

    var deps = ["$scope", "$state", "$modal", "$stateParams", "MessageBox", "MuseService"];

    function controller ($scope, $state, $modal, $stateParams, MessageBox, MuseService) {
        //获取参数
        var userId = $stateParams.userId = $stateParams.userId || '';

        //获取数据
        $scope.getDetail = function () {
            MuseService.post("admin/adminuser/" + userId + "/edit.json").success(
                function (data, status, headers, config) {
                    if (data.state == 0) {
                        $scope.user = data.data;
                    } else {
                        MessageBox.notify('获取数据失败:' + data.message);
                    }
                });
        };
        if (userId) {
            $scope.getDetail();
        }

        //获取“选择角色”下拉框数据
        $scope.getAdminRoleList = function () {
            MuseService.post("admin/adminrole/list.json").success(
                function (data, status, headers, config) {
                    if (data.state == 0) {
                        $scope.adminRoleList = data.data;
                    } else {
                        MessageBox.notify('获取信息失败：' + data.message);
                    }
                });
        };
        $scope.getAdminRoleList();

        // 取消，返回
        $scope.close = function () {
            $state.go("MessageLogList");
        };
    }

    controller.$inject = deps;
    app.lazy.controller("MessageLogEditController", controller);
});
